﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SIGGREProto
{
    class UtilMail
    {

        //http://www.velocityreviews.com/forums/t592366-send-mail-with-gmail.html
        public static void SendGmail(string userName, string password,
                string mailFrom,
                string mailTo, string commaDelimCCs, string
                subject, string message, bool isBodyHtml)
        {
            System.Net.Mail.MailMessage msg = new
            System.Net.Mail.MailMessage(mailFrom, mailTo,
            subject, message);
            msg.IsBodyHtml = isBodyHtml;
            if (commaDelimCCs != "")
                msg.CC.Add(commaDelimCCs);
            System.Net.NetworkCredential cred = new
            System.Net.NetworkCredential(userName, password);
            System.Net.Mail.SmtpClient mailClient = new
            System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
            mailClient.EnableSsl = true;
            mailClient.UseDefaultCredentials = false;
            mailClient.Credentials = cred;
            mailClient.Send(msg);
        }

        public static void testGmail()
        {                        
            SendGmail("gerson.freire@gmail.com", "gersonfaf61", "gerson.freire@gmail.com", 
                "gerson.freire@terra.com.br", "gerson.projetos@gmail.com", "teste", "teste", false);
        }
    }
}
